Skip to content

Sheffield | May-2025 | WALEED-YAHYA SALIH-TAHA | Sprint-3 #652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 50 commits into
base: main
Choose a base branch
from

Conversation

Bluejay600
Copy link

@Bluejay600 Bluejay600 commented Jul 11, 2025

Learners, PR Template

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with REGION | COHORT_NAME | FIRST_NAME LAST_NAME | PROJ_NAME
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist

Sprint-3 is mainly about implementing, rewriting, practicing and and testing functions.

Questions

Ask any questions you have for your reviewer.

2. identified obtuse angle and it's function
3. identified stright angle and it's function
4. identified reflex anglewith it's function.
2. Identified Obtuse angles when it's greater than 90 degrees and less than 180, and added a line to test the function.
3. added a line to test all the if conditions in the program.
2. tested other scenarios like Zero numerator
@Bluejay600 Bluejay600 added 📅 Sprint 3 Assigned during Sprint 3 of this module Needs Review Participant to add when requesting review labels Jul 11, 2025
Copy link
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sprint-3/4-stretch-investigate/password-validator.js
Sprint-3/4-stretch-investigate/password-validator.test.js

I noticed the code in the above two files were partially modified buy they are not yet fully implemented. Since "stretch" exercises are optional, I will only comment when they are fully implemented.

Comment on lines +17 to +24
console.log(getAngleType(90)); // Right angle
console.log(getAngleType(135)); // Obtuse angle
console.log(getAngleType(180)); // Straight angle
console.log(getAngleType(270)); // Reflex angle
console.log(getAngleType(0)); // Invalid angle
console.log(getAngleType(360)); // Invalid angle
console.log(getAngleType(-10)); // Invalid angle
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused code or code used solely for development purposes should be removed or, at the very least, commented out with clear justification.

Comment on lines +52 to +53
const zeroNumerator = isProperFraction(0, 5);
assertEquals(zeroNumerator, true); // ✅ should pass
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically 0 is not considered a proper fraction. :)

const rank = card.slice(0, -1); // Get the rank (everything except the last character)
if (rank === "A") return 11;
if (["J", "Q", "K"].includes(rank)) return 10;
if (rank >= "2" && rank <= "9") return parseInt(rank, 10);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strings are compared differently in the JS language.

Does your function return the value you expected from each of the following function calls?

getCardValue("333♠");
getCardValue("3.1416♠");
getCardValue("3ABC♠");

Comment on lines +4 to +8
test("should return 5 for 5 of Hearts", () => {
const fiveofHearts = getCardValue("5♥");
expect(fiveofHearts).toEqual(5);
});

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When preparing tests, we should ensure the tests cover all possible cases. If we specify a test for individual card, we will need about 53 tests to cover all possible cases. Instead, we could consider classifying all possible values into different categories, and then within each category we test some samples.

For example, one possible category for getCardValue() is, "should return the value of number cards (2-10)", and we can prepare the test as

test("should return the value of number cards (2-10)", () => {
    expect(getCardValue("2♣︎")).toEqual(2);
    expect(getCardValue("5♠")).toEqual(5);
    expect(getCardValue("10♥")).toEqual(5);
    // Note: We could also use a loop to check all values from 2 to 10.
});

Comment on lines +10 to +21
test("should return 10 for Jack of Diamonds", () => {
const jackOfDiamonds = getCardValue("J♦");
expect(jackOfDiamonds).toEqual(10);
});
test("should return 10 for Queen of Clubs", () => {
const queenOfClubs = getCardValue("Q♣");
expect(queenOfClubs).toEqual(10);
});
test("should return 10 for King of Spades", () => {
const kingOfSpades = getCardValue("K♠");
expect(kingOfSpades).toEqual(10);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also combine these tests into one under the category "should return 10 for face cards (J, Q, K)".

Comment on lines +1 to +10
function countChar(stringOfCharacters, findCharacter) {
// Initialize a counter
let count = 0;

// Scenario: Multiple Occurrences
// Given the input string str,
// And a character char that may occur multiple times with overlaps within str (e.g., 'a' in 'aaaaa'),
// When the function is called with these inputs,
// Then it should correctly count overlapping occurrences of char (e.g., 'a' appears five times in 'aaaaa').
// Loop through the string
for (let char of stringOfCharacters) {
if (char === findCharacter) {
count++;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why defined another countChar() function in this script? The code in this script is supposed to test the function implemented in Sprint-3/3-mandatory-practice/implement/count.test.js.

function getOrdinalNumber(num) {

module.exports = getOrdinalNumber;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The statement module.exports = ... should be placed outside of any function block; usually at the end of the file.

Comment on lines +14 to +19
return "1st";
} else if (num === 2) {
return "2nd";
} else if (num === 3) {
return "3rd";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just rely on the code at lines 20-25 to handle these three specific numbers?

Comment on lines +19 to +21
test("should return '2nd' for 2", () => {
expect(getOrdinalNumber(2)).toEqual("2nd");
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To ensure thorough testing, we need broad scenario coverage. Listing individual values, however, can quickly lead to an unmanageable number of test cases.
Instead of writing tests for individual numbers, consider grouping all possible input values into meaningful categories. Then, select representative samples from each category to test. This approach improves coverage and makes our tests easier to maintain.

For example, we can prepare a test for numbers 2, 22, 132, etc. as

test("append 'nd' to numbers ending in 2, except those ending in 12", () => {
    expect( getOrdinalNumber(2) ).toEqual("2nd");
    expect( getOrdinalNumber(22) ).toEqual("22nd");
    expect( getOrdinalNumber(132) ).toEqual("132nd");
});

Can you update the tests in this script so that they can cover all valid integers?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not delete the code at lines 1-3?

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review and removed Needs Review Participant to add when requesting review labels Jul 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reviewed Volunteer to add when completing a review 📅 Sprint 3 Assigned during Sprint 3 of this module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants